/*
 * @Author: wangwang 2723008256@qq.com
 * @Date: 2022-07-08 14:29:44
 * @LastEditors: wangwang 2723008256@qq.com
 * @LastEditTime: 2023-06-12 17:03:07
 * @FilePath: \jzjypc4.0\src\utils\time.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

export  function timeStamp2String(time, type) { // time=>时间戳、 type=>转换类型
    var datetime = new Date();
    datetime.setTime(time);
    var year = datetime.getFullYear();
    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
    var month0 =  datetime.getMonth() + 1;
    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
    var date0 =  datetime.getDate();
    var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
    var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
    var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
    var monthNo0 = datetime.getMonth() + 1
    var dateNo0 = datetime.getDate()
    if (type == '1') {
        return year + "年" + month + "月" + date + "日";
    }
    if (type == '2') {
        return year + "-" + month + "-" + date;
    }
    if (type == '3') {
        return month + "-" + date;
    }
    if (type == '4') {
        return month;
    }
    if (type == '5') {
        return hour + ":" + minute
    }
    if (type == '6') {
        return year + "." + month + "." + date + " " + hour + ":" + minute + ":" + second;
    }
    if (type == '7') {
        return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
    }
    if (type == '8') {
        return year + "-" + month + "-" + date + "    " + hour + ":" + minute;
    }
    if (type == '9') {
        return month + "-" + date + " " + hour + ":" + minute;
    }
    if(type == '10'){ //获取时间戳是几号
        return date
    }
    if(type == '11'){ //获取星期几
        if(new Date(time).getDay() == 1){
            return '星期一'
        }else if(new Date(time).getDay() == 2){
            return '星期二'
        }else if(new Date(time).getDay() == 3){
            return '星期三'
        }else if(new Date(time).getDay() == 4){
            return '星期四'
        }else if(new Date(time).getDay() == 5){
            return '星期五'
        }else if(new Date(time).getDay() == 6){
            return '星期六'
        }else if(new Date(time).getDay() == 0){
            return '星期日'
        }
    }
    if(type == '12'){
        return year  + month + date;
    }
    if(type == '13'){
        return monthNo0  + "月" +dateNo0 + '日'
    }
    if(type == '14'){
        return year  + "-" +month + '-'
    }
    if(type == '15'){ //获取时间戳是几号
        return date0
    }
    if (type == '16') {
        return month0; //单数月份前面不加0
    }
    if (type == '17') {
        return year;
    }
}